#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int maxGroups(int n, int a[]) 
{
    int count = 0;
    int odd = 0, even = 0;
    int groups = 0;

    for (int i = 0; i < n; i++)
    {
        if (a[i] % 2 == 0) 
        {
            even++;
        }
        else 
        {
            odd++;
        }

        if (odd == even) 
        {
            groups++;
            odd = 0;
            even = 0;
        }
    }

    if (odd != 0 || even != 0)
    {
        return -1;
    }

    return groups;
}

int main() 
{
    int n;
    scanf("%d", &n);

    int* a=(int*)malloc(sizeof(int)*n);
    for (int i = 0; i < n; i++) 
    {
        scanf("%d", &a[i]);
    }

    int result = maxGroups(n, a);
    printf("%d\n", result);
    free(a);
    return 0;
}